<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //ATM案例
        var bank = 100; //现有的100
        do {
            var num = prompt('请输入您要操作的指令：\n 1.存钱\n 2.取钱\n 3.显示余额\n 4.退出');
            switch (num) {
                case '1':
                    var num1 = prompt('请输入您存入的金额：');
                    bank = bank + parseFloat(num1);
                    alert('存入成功！！！您的余额为：' + bank);  
                    break;
                case '2':
                    var num2 = prompt('请输入您要取出的金额：');
                    // bank = bank - parseFloat(num2);
                    // alert('取出成功！！！您的余额为：' + bank);
                    if(parseFloat(num2) <= bank) {
                        bank = bank - parseFloat(num2);
                    alert('取出成功！！！您的余额为：' + bank);
                    }  else{
                        alert('您的余额不足！！');
                    }              
                    break;
                case '3':
                    alert('您的余额为：' + bank);
                    break;
                case '4':
                    alert('退出成功！！！');
            }
        } while (num > 5);
        alert('请输入正确的操作指令');
    </script>
</head>
<body>
    
</body>
</html>